//
//  CLTools.h
//  touguApp
//
//  Created by 夏成龙 on 16/6/27.
//  Copyright © 2016年 夏成龙. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "Masonry.h"

#define RGB(r, g, b) [UIColor colorWithRed:r / 255.0 green:g / 255.0  blue:b / 255.0  alpha:1.0]
#define GRAYRGB(c) [UIColor colorWithRed:c / 255.0 green:c / 255.0  blue:c / 255.0  alpha:1.0]
typedef enum : NSUInteger {
    iphoneType7Plus,
    iphoneType7,
    iphoneTypeSE,
    iphoneType6sPlus,
    iphoneType6s,
    iphoneType6,
    iphoneType5s,
    iphoneType5c,
    iphoneType5,
    iphoneType4s,
    iphoneType4,
    iphoneType3GS,
    iphoneType3G,
    iphoneType2G,
    
} iphoneType;

#define PlaceholderImage  [UIImage imageNamed:@"imageHeader"]



@interface ECTCLTools : NSObject

+ (UIBarButtonItem *)leftBarButtonItem:(UIViewController *)viewController target:(id)target action:(SEL)action;

//+ (UIBarButtonItem *)barButtonItem:(UIViewController *)viewController title:(NSString *)title selectedTitle:(NSString *)selectedTitle titleColor:(UIColor *)titleColor imageName:(NSString *)imageName selectedImage:(NSString *)selectedImage backgroundImage:(NSString *)backgroundImage selecgedgroundImage:(NSString *)selecgedgroundImage target:(id)target action:(SEL)action;

+ (UIButton *)buttonTitle:(NSString *)title frame:(CGRect)frame font:(NSInteger)font titleColor:(UIColor *)titleColor imageName:(id)imageName  backgroundImage:(id)backgroundImage target:(id)target action:(SEL)action superView:(UIView *)superView constraintMaker:(void(^)(MASConstraintMaker *make))make;

+ (UILabel *)labelWithTitle:(NSString *)title titleColor:(UIColor *)titleColor font:(CGFloat)font frame:(CGRect)frame superView:(UIView *)superView constraintMaker:(void (^)(MASConstraintMaker *make))make;

+ (UIImageView *)imageViewWithImageName:(NSString *)imageName frame:(CGRect)frame superView:(UIView *)superView constraintMaker:(void (^)(MASConstraintMaker *make))make;

+ (UIView *)viewWithBackgroundColor:(UIColor *)backgroundColor frame:(CGRect)frame superView:(UIView *)superView constraintMaker:(void(^)(MASConstraintMaker *make))make;

+ (UIImage *)imageWithColor:(UIColor *)color;
/** 通过字符串获得图片 */
+ (UIImage *)imageFromText:(NSString *)text withAttribute:(NSDictionary *)attribute font:(CGFloat)fontSize maxWidth:(CGFloat)maxWidth;

/**
 *  将字典写入缓存
 */
+ (BOOL)writeDataToCacheWithData:(NSDictionary *)data identifier:(NSString *)identifier currentClass:(Class)currentClass;
/**
 *  从本地缓存中读取数据
 */
+ (NSDictionary *)readDataFromCacheWithIdentifier:(NSString *)identifier currentClass:(Class)currentClass;
/**
 *  删除本地的缓存
 */
+ (BOOL)removeDataToCacheWithIdentifier:(NSString *)identifier currentClass:(Class)currentClass;

+ (void)getRequestWithPath:(NSString *)path parms:(NSDictionary *)parms success:(void(^)(NSDictionary *response))success fail:(void(^)(NSError * fail))fail;

+ (void)postRequestWithPath:(NSString *)path parms:(NSDictionary *)parms success:(void(^)(NSDictionary *response))success fail:(void(^)(NSError * fail))fail;

//获得搜索富文本字符串
+ (NSMutableAttributedString *)getAttributeStingWithTargetContentTextString:(NSString *)textStrng tagArray:(NSArray *)tagArray atrributDict:(NSDictionary *)attributeDict;
+ (NSString *)getTimeStrWithDate:(NSInteger)date;
//对时间做处理
+ (NSString *)convertTimeWithTimeInterval:(long)timeInterVal;

/**
 * 获得价格字符串
 */
+ (NSString *)getPriceStringWithPrice:(CGFloat)price;
/**
 * 获得金额字符串
 */
+ (NSString *)getMoneyFormatString:(NSString *)moneyString perString:(NSString *)perString;

//价格显示到小数点后两位，末尾0不显示，传过来的是%.2f的字符串
+ (NSString *)convertWithPriceStr:(NSString *)priceStr;


+ (iphoneType)getIphoneType;
/*
 通过色值字符串获得颜色
 */
+ (UIColor *)getColorFromString:(NSString *)cString;
@end
